import { defineStore } from "pinia";
import axios from "axios";
import { nanoid } from "nanoid";

export const useTalkStore = defineStore("talkStore", {
  actions: {
    async getATalk() {
      let result = await axios.get("https://api.shadiao.pro/chp");
      // console.log(result.data.data.text);

      let obj = { id: nanoid(), title: result.data.data.text };
      console.log(obj);
      this.talkList.unshift(obj);
    },
  },

  state() {
    return {
      talkList: [
        { id: "00001", title: "土味情话一" },
        { id: "00002", title: "土味情话二" },
        { id: "00003", title: "土味情话三" },
      ],
    };
  },
});
